<template>
	<view>
		<!-- 搜索 -->
		<view>
			<view>
				<uni-view data-v-cf183850="" class="cu-bar search bg-white">
					<uni-view data-v-cf183850="" class="search-form round">
						<uni-text data-v-cf183850="" class="cuIcon-search"><span></span></uni-text>
						<uni-input data-v-cf183850="">
							<div class="uni-input-wrapper">
								<div class="uni-input-placeholder input-placeholder" data-v-cf183850=""></div>
								<!---->
								<form action="" class="uni-input-form">
									<input maxlength="140" step="" enterkeyhint="search" v-model="key"
										autocomplete="off" type="search" class="uni-input-input">
								</form>
							</div>
						</uni-input>
					</uni-view>
					<uni-view data-v-cf183850="" class="action">
						<uni-button data-v-cf183850="" class="cu-btn bg-green shadow-blur round" @click="goSearch">搜索
						</uni-button>
					</uni-view>
				</uni-view>
			</view>
			<view style="display: flex;flex-wrap: wrap;">
				<template v-for="(item,index) in keyWords">
					<view @click='changeKey(item)' style="border: 1upx solid #0A98D5;margin-left: 20upx;margin-top: 10upx;">
						{{item}}
					</view>
				</template>
			</view>
		</view>
		<view style="width: 500rpx;">
			<template v-for="(item,index) in goodsDate">
				<view @click='details(item)'>
					名称：{{item.goodsName}}
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				key: "",
				goodsDate: [],
				keyWords: ['猴头菇', '创口贴', '板蓝根','加湿器','云南白药','燕窝','山药','跑步机']
			}
		},
		methods: {
			changeKey(item) {
				this.key = item;
			},
			goSearch() {
				this.$req.searchByKeyWords(this.key, 0, 3).then(res => {
					console.log(res)
					this.goodsDate = res;
				})
			},
			backToUploadVideo(item) {
				uni.setStorageSync("goodsForVideo", item);
				uni.navigateBack({
					delta: 2
				})
			},
			details(item) {
				uni.showModal({
					title: '选择商品',
					content: '确定选择该商品？',
					success: (res) => {
						if (res.confirm) {
							this.backToUploadVideo(item);
						} else if (res.cancel) {}
					}
				});
			}
		}
	}
</script>

<style>
</style>
